﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AnonymousMethodEx
{
    class AnonymousMethodEx
    {
        /// <summary>
        /// 申明一个委托
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        delegate void CalaulateDelegate(Int32 x, Int32 y);

        static void Main(string[] args)
        {
            ///匿名方法
            CalaulateDelegate mySubstractDelegate = delegate(Int32 x, Int32 y)
            {
                Console.WriteLine(x - y);
            };
            CalaulateDelegate myAddDelegate = delegate(Int32 x, Int32 y)
            {
                Console.WriteLine(x + y);
            };
            mySubstractDelegate(300, 100);
            myAddDelegate(300, 100);
            
            Console.ReadKey();
        }

    }

}
